<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) {
	die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
}

/**
*
* @package MediaLibrary
* @copyright 2009 Andrey Kvasnevskiy-OrdaSoft(akbet@mail.ru);Rob de Cleen(rob@decleen.com)
* Homepage: http://www.joomlawebserver.com
* @version: 1.5.3 Basic $
*
**/




$mosConfig_absolute_path = $GLOBALS['mosConfig_absolute_path']	= JPATH_SITE;

require_once($mosConfig_absolute_path."/administrator/components/com_medialibrary/compat.joomla1.5.php");
require_once($mosConfig_absolute_path."/administrator/components/com_medialibrary/install.medialibrary.helper.php");
require_once ($mosConfig_absolute_path."/administrator/components/com_medialibrary/admin.medialibrary.class.impexp.php");


function com_install()
{

global $database,$mosConfig_absolute_path,$mosConfig_live_site;
//*******************************   begin check version PHP   **********************************
$is_warning = false;

if ( (phpversion()) < 5 ) { 
	?>
<center>
<table width="100%" border="0">
  <tr>
    <td>
      <code>Installation status: <font color="red">fault</font></code>
    </td>
  </tr>
  <tr>
    <td>
      <code><font color="red">This component works correctly under PHP version 5.0 and higher.</font></code>
    </td>
  </tr>
</table>
</center>

<?php
return '<h2><font color="red">Component installation fault</font></h2>';
}

//********************************   end check version PHP   ***********************************

if ( !(function_exists('use_soap_error_handler') || function_exists('is_soap_fault')) ) {
  ?>
<center>
<table width="100%" border="0">
  <tr>
    <td>
      <code>Installation status: <font color="red">fault</font></code>
    </td>
  </tr>
  <tr>
    <td>
      <code><font color="red">SOAP extension not found! In order for MediaLibrary Web Services to work, you need to compile PHP5 with support for the SOAP extension!</font></code>
    </td>
  </tr>
</table>
</center>
<?php
return '<h2><font color="red">Component installation fault</font></h2>';

}
//********************************   end check SOAP   ******************************************

//********************************   begin check xsl extension   *******************************
if ( !(class_exists('XsltProcessor')) ) {
$is_warning = true;
?>
<center>
<table width="100%" border="0">
  <tr>
    <td>
      <code><font color="red">XSL extension not found! In order for csv export to work, you need to compile PHP5 with support for the XSL extension!</font></code>
    </td>
  </tr>
</table>
</center>
<?php
}
//********************************   end check xsl extension   *********************************
//********************************   begin check CURL extension   *******************************
if ( !(function_exists('curl_init')) ) {
$is_warning = true;
?>
<center>
<table width="100%" border="0">
  <tr>
    <td>
      <code><font color="red">CURL extension not found! In order for book cover download to work, you need to compile PHP5 with support for the CURL extension!</font></code>
    </td>
  </tr>
</table>
</center>
<?php
}
//********************************   end check CURL extension   *********************************
//********************************   begin check GD extension   *******************************
if ( !(function_exists('imagefontwidth')) ) {
$is_warning = true;
?>
<center>
<table width="100%" border="0">
  <tr>
    <td>
      <code><font color="red">GD extension not found! In order for CAPTCHA picture works correctly, you need to compile PHP5 with support for the GD extension!</font></code>
    </td>
  </tr>
</table>
</center>
<?php
}
//********************************   end check GD extension   *********************************
DMInstallHelper::setAdminMenuImages();

//add simple data
mosMediaLibraryImportExport :: importMediasXML($mosConfig_absolute_path."/administrator/components/com_medialibrary/exports/sample_data.xml",null);

# Show installation result to user
?>
<center>
<table width="100%" border="0">
  <tr>
    <td>
      <strong>MediaLibrary</strong><br/>
      <br/>
      This component is published under the <a href="<?php echo $mosConfig_live_site."/components/com_medialibrary/doc/LICENSE.txt"; ?>"
       target="new">License</a>.
    </td>
  </tr>
  <tr>
    <td>
      <code>Installation: <font color="green">succesful</font></code>
    </td>
  </tr>
</table>
</center>

<?php
if($is_warning) return '<h2><font color="red">The MediaLibrary Component installed with a warning about a missing PHP extension! Please read carefully and uninstall MediaLibrary. Next fix your PHP installation and then install MediaLibrary again.</font></h2>';
}
?>
